package com.xpec.c4.service.module.common;

import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;

import com.ms.game.gmtool.message.SGmtoolUpdateItemInfos;
import com.ms.service.module.common.message.SPlayerCommonInfo;
import com.xpec.c4.game.utility.GameUtility;
import com.xpec.c4.message.MessageTypes;
import com.xpec.c4.service.annotations.MessageType;
import com.xpec.c4.service.annotations.Name;
import com.xpec.c4.service.common.BaseMessageAction;
import com.xpec.c4.service.contexts.Contexts;
import com.xpec.c4.service.contexts.ScopeType;

@Name(scopeType = ScopeType.SESSION)
public class CommonAction extends BaseMessageAction {

	@SuppressWarnings("unused")
	private static final Log log = LogFactory.getLog(CommonAction.class);

	@MessageType(typeCode = MessageTypes.S_PLAYER_COMMON_INFO)
	public void onPlayerCommonInfoChanged(SPlayerCommonInfo obj) {
		try{
			((CommonModule) Contexts.getModule()).onPlayerCommonInfoChanged(obj);	
		}catch(Exception e){
			if(log.isErrorEnabled()){
				log.error(GameUtility.getCurMethodName(), e);
			}
		}
		
	}
	
	@MessageType(typeCode = MessageTypes.S_UPDATE_ITEM_BOX)
	public void onUpdateItemBox(Object request){
		SGmtoolUpdateItemInfos updateItemInfos =  (SGmtoolUpdateItemInfos)request;		
		if(updateItemInfos == null){
			return;
		}
		
		if(updateItemInfos.getType() < 1){
			return;
		}
		
		((CommonModule) Contexts.getModule()).onUpdateItemBox(updateItemInfos);
	}
}
